﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using DTO;
using System.Data.SqlClient;


namespace DAO
{
   public class DangKyLichDiDAO
    {
       public bool DangKyLichDi(DangKyLichDiDTO nvdk)
       {
           Data dt = new Data();
           string proc = "sp_nvdangkylichdi";
           SqlParameter[] p={
                                new SqlParameter("@manv",SqlDbType.VarChar,10){Value=nvdk.MaNV},
                                new SqlParameter("@matuyen",SqlDbType.Int){Value=nvdk.MaTuyen},
                                new SqlParameter("@maxe",SqlDbType.Int){Value=nvdk.MaXe},
                                new SqlParameter("@ngaydi",SqlDbType.DateTime){Value=nvdk.NgayDi}
                            };

           return dt.ExecuteNonQuery(proc, p);
          
       }
       public bool themslDangKyLichDi(DangKyLichDiDTO nvdk)
       {
           Data dt = new Data();
           string proc = "sp_NVDangKyLichDiup";
           SqlParameter[] p ={
                                new SqlParameter("@manv",SqlDbType.VarChar,10){Value=nvdk.MaNV},
                                new SqlParameter("@matuyen",SqlDbType.Int){Value=nvdk.MaTuyen},
                                new SqlParameter("@maxe",SqlDbType.Int){Value=nvdk.MaXe},
                                new SqlParameter("@ngaydi",SqlDbType.DateTime){Value=nvdk.NgayDi}
                            };

           return dt.ExecuteNonQuery(proc, p);

       }
       public DataTable DanhSachLichDi(string sql)
       {
           Data dv = new Data();
           return dv.ExecuteQueryWithSQLParameter(sql);
       }

       public bool HuyDangKyLichDi(DangKyLichDiDTO ld)
       {
           Data dv = new Data();
           string proc = "sp_huylichdidadangky";
           SqlParameter[] p = { 
                                new SqlParameter("@manv",SqlDbType.VarChar,10){Value=ld.MaNV},
                                new SqlParameter("@matuyen",SqlDbType.Int){Value=ld.MaTuyen},
                                new SqlParameter("@maxe",SqlDbType.Int){Value=ld.MaXe},
                                new SqlParameter("@ngaydi",SqlDbType.DateTime){Value=ld.NgayDi}
                              };

           return dv.ExecuteNonQuery(proc, p);

       }
       public bool HuyslDangKyLichDi(DangKyLichDiDTO ld)
       {
           Data dv = new Data();
           string proc = "sp_huylichdidadangkyup";
           SqlParameter[] p = { 
                                new SqlParameter("@manv",SqlDbType.VarChar,10){Value=ld.MaNV},
                                new SqlParameter("@matuyen",SqlDbType.Int){Value=ld.MaTuyen},
                                new SqlParameter("@maxe",SqlDbType.Int){Value=ld.MaXe},
                                new SqlParameter("@ngaydi",SqlDbType.DateTime){Value=ld.NgayDi}
                              };

           return dv.ExecuteNonQuery(proc, p);

       }
    }
}
